package com.lgl.scsheader.sameCityChart.controller;

import com.lgl.scsapi.system.model.PageData;
import com.lgl.scsapi.system.model.SysUser;
import com.lgl.scsheader.base.controller.BaseController;
import com.lgl.scsheader.sameCityChart.service.UserInfoChartService;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 用户相关统计图表
 */

@RestController
@RequestMapping(value="/userInfoChart")
public class UserInfoChartController extends BaseController{
	@Resource(name="userInfoChartService")
	private UserInfoChartService userInfoChartService;

    //获取每个月用户注册数
    @RequestMapping(value = "/listMonthUserRegisterNum")
    public Object listMonthUserRegisterNum(){
        return userInfoChartService.listMonthUserRegisterNum(getPageData());
    }
    //获取某年所有月份的登录用户数
    @RequestMapping(value = "/listLoginOfUserNum")
    public Object listLoginOfUserNum(){
        PageData userPd = getPageData();
        SysUser user = getSessionUser();
        //如果有月份，则说明是查某个月的用户登录数
        if (StringUtils.hasText(userPd.getString("thisMonth"))){
            return userInfoChartService.listMonthLoginUserNum(user,userPd);
        }
        return userInfoChartService.listYearLoginUserNum(user,userPd);
    }
    //获取平台上所有用户各年龄的数量及占比
    @RequestMapping(value = "/listAllUserAgeSection")
    public Object listAllUserAgeSection(){
        return userInfoChartService.listAllUserAgeSection();
    }
    //获取各等级的用户数量及占比
    @RequestMapping(value = "/listLevelUserNum")
    public Object listLevelUserNum(){
        return userInfoChartService.listLevelUserNum();
    }
    //获取用户男女的数量
    @RequestMapping(value = "/listSexUserNum")
    public Object listSexUserNum(){
        return userInfoChartService.listSexUserNum();
    }
    //获取热门城市用户的数量
    @RequestMapping(value = "/listHotCityUserNum")
    public Object listHotCityUserNum(){
        return userInfoChartService.listHotCityUserNum();
    }
    //获取手机/微信等用户类型的数量
    @RequestMapping(value = "/listClientUserNum")
    public Object listClientUserNum(){
        return userInfoChartService.listClientUserNum();
    }
}